import request from '../../utils/request';

// 商品分类管理相关 API

// 更新商品分类
export const updateProductCategory = (data: any) => {
    return request({
        url: '/product/api/category',
        method: 'put',
        data
    });
};

// 新增商品分类
export const createProductCategory = (data: any) => {
    return request({
        url: '/product/api/category',
        method: 'post',
        data
    });
};

// 获取分类详情
export const getProductCategoryDetail = (id: string) => {
    return request({
        url: `/product/api/category/${id}`,
        method: 'get'
    });
};

// 删除商品分类
export const deleteProductCategory = (id: string) => {
    return request({
        url: `/product/api/category/${id}`,
        method: 'delete'
    });
};

// 根据父分类ID获取子分类
export const getProductCategoryChildren = (parentId: string) => {
    return request({
        url: `/product/api/category/children/${parentId}`,
        method: 'get'
    });
};

// 分页查询分类列表
export const getProductCategoryPage = (params: any) => {
    return request({
        url: '/product/api/category/page',
        method: 'get',
        params
    });
};

// 获取分类树形结构
export const getProductCategoryTree = () => {
    return request({
        url: '/product/api/category/tree',
        method: 'get'
    });
};
